package com.etoak.controller;


import com.etoak.common.core.vo.ResultVO;
import com.etoak.dto.LoginDTO;
import com.etoak.service.UserService;
import com.etoak.vo.AccessToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * UserController
 * </p>
 *
 * @author etoak
 * @since 2024-12-23
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    /**
     * 登录接口 post /user/login
     * 参数类型: x-www-form-urlencoded
     */
    @PostMapping("/login")
    public ResultVO<AccessToken> login(@Validated LoginDTO loginDTO) {
        AccessToken accessToken = userService.login(loginDTO);
        return ResultVO.success(accessToken);
    }
}

